<?php

require_once dirname(__FILE__) . '/../lib/cajaGeneratorConfiguration.class.php';
require_once dirname(__FILE__) . '/../lib/cajaGeneratorHelper.class.php';

/**
 * caja actions.
 *
 * @package    tercermilenio
 * @subpackage caja
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 12474 2008-10-31 10:41:27Z fabien $
 */
class cajaActions extends autoCajaActions {

    public function executeGenerarBalance(sfWebrequest $request) {

        //Total de ventas del día en efectivo
        $this->ventas_efectivo = CajaPeer::obtenerVentasDelDiaEnEfectivo();
        $total = "";
        if (!empty($this->ventas_efectivo)) {
            foreach ($this->ventas_efectivo as $vta) {
                $totalVta = $vta->getVtaEfectivo();
                $total = $total + $totalVta;
            }
        }
        $this->total_efectivo = $total;

        //Total de ventas del día en cuenta corriente
        $this->ventas_cta_cte = CajaPeer::obtenerVentasDelDiaEnCtaCte();
        $total = "";
        if (!empty($this->ventas_cta_cte)) {
            foreach ($this->ventas_cta_cte as $vta) {
                $totalVta = $vta->getVtaCtaCte();
                $total = $total + $totalVta;
            }
        }
        $this->total_cta_cte = $total;

        //Total de ventas del día en efectivo y cuenta corriente
        $this->ventas_efectivo_cta_cte = CajaPeer::obtenerVentasDelDiaEnEfectivoCtaCte();
        $total = "";
        if (!empty($this->ventas_efectivo_cta_cte)) {
            foreach ($this->ventas_efectivo_cta_cte as $vta) {
                $totalVta = $vta->getVtaEfectivo() + $vta->getVtaCtaCte();
                $total = $total + $totalVta;
            }
        }
        $this->total_efectivo_cta_cte = $total;
    }

}
